package com.itwxz.system.controller.mobile;


import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.itwxz.common.core.controller.BaseController;
import com.itwxz.common.core.domain.R;
import com.itwxz.system.domain.po.WxzCarousel;
import com.itwxz.system.enums.carousel.CarouselStatus;
import com.itwxz.system.service.IWxzCarouselService;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.RequiredArgsConstructor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cache.annotation.Cacheable;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * 轮播图Controller
 *
 * @author gastronome
 * @date 2025-04-29
 */
@Tag(name = "轮播图Controller")
@RestController
@RequestMapping("/mobile/carousel")
@RequiredArgsConstructor
public class WxzCarouselMobileController extends BaseController {
	private final IWxzCarouselService carouselService;

	@GetMapping("/list")
	@Cacheable(value = "carousel", key = "'list'")
	public R<List<WxzCarousel>> list() {
		LambdaQueryWrapper<WxzCarousel> queryWrapper = new LambdaQueryWrapper<>();
		queryWrapper
				.eq(WxzCarousel::getStatus, CarouselStatus.ENABLED)
				.orderByAsc(WxzCarousel::getSortOrder);
		return R.ok(carouselService.list(queryWrapper));
	}
}
